﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using System.Reflection;

namespace 属性改变通知
{
    public abstract class BaseSagaData : INotifyPropertyChanged
    {
        protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        private object _childInstance;
        protected BaseSagaData(string sagaId)
        {
            SagaId = sagaId ?? throw new ArgumentNullException(nameof(sagaId));
            LoadData();
        }

        private void BaseSagaData_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            lock (this)
            {
                Console.WriteLine("修改通知触发");
            }
        }

        public bool LoadData()
        {
            lock (this)
            {
                Console.WriteLine("加载值 ");

                return true;
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public string SagaId { get; set; }
        public abstract bool IsDone();

    }
}
